﻿namespace MicroCloud.Identity
{
    /// <summary>
    /// 身份标识模块
    /// <para>此模块必须在MVC模块之前启动</para>
    /// </summary>
    [Description("身份标识模块")]
    public class IdentityPack : IdentityPackBase<UserStore, RoleStore, OrganizationStore, User, long, UserClaim, long, Role, long, Organization, long>
    {
        /// <summary>
        /// 将模块服务添加到依赖注入服务容器中
        /// </summary>
        /// <param name="services">依赖注入服务容器</param>
        /// <returns></returns>
        public override IServiceCollection AddServices(IServiceCollection services)
        {
            services.AddScoped<IIdentityContract, IdentityService>();

            services.AddSingleton<IMapTuple, AutoMapperIdentityConfiguration>();

            services.AddSingleton<ISeedDataInitializer, RoleSeedDataInitializer>();
            services.AddSingleton<ISeedDataInitializer, OrganizationSeedDataInitializer>();
            services.AddSingleton<ISeedDataInitializer, UserSeedDataInitializer>();

            services.AddEventHandler<LoginLogEventHandler>();
            services.AddEventHandler<LogoutLogEventHandler>();

            return base.AddServices(services);
        }

    }

}
